import { createRouter, createWebHistory } from "vue-router";

const LayoutContainer = () => import("@/layout/index.vue");

// 路由配置
const routes = [
  {
    path: "/",
    redirect: "/home",
    component: LayoutContainer,
    children: [
      {
        path: "home",
        name: "Home",
        component: () => import("@/views/Home/index.vue"),
        meta: { title: "首页", icon: "el-icon-house" },
      },
    ],
  },
];

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes,
});

// 全局前置守卫
router.beforeEach((to, from, next) => {
  // 路由跳转前的逻辑
  next();
});

// 全局后置钩子
router.afterEach((to, from) => {
  // 路由跳转后的逻辑
});

export default router;
